/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kpiwatcher;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.mapping.List;
import store.HibernateUtil;
import store.Persona;

/**
 *
 * @author giuliogenna
 */
public class PersonaUnitTest {
    public static void main(String[] args){
        System.out.println("Persona Unit Test");
        //Session session= new Configuration().configure().buildSessionFactory().getCurrentSession();
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    
    Persona person = new Persona();
    
    /*person.setId(101);
    person.setNome("Giulio");
    person.setPromo("g.genna@gmail.com");
    * 
    */
   
    session.beginTransaction();
    
    session.save(person);
    
    Query q= session.createQuery("from Persona where nome=:nome ");
    q.setParameter("nome", "Giulio");
    java.util.List list = q.list();
    
    session.getTransaction().commit();
        Persona get = (Persona) list.get(0);
        System.out.println(get.getPromo());
    System.out.println(person.getNome());
    
    
    
    
            
      
       
    }
    
}
